//
//  BRInviteRecordListCell.m
//  Kexu
//
//  Created by IOS on 2023/7/27.
//

#import "BRInviteRecordListCell.h"

@implementation BRInviteRecordListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUI];
    }
    return self;
}

#pragma mark - UI --
- (void)setUI {
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    
    UIView *contView = [UIView new];
    contView.backgroundColor = UIColor.whiteColor;
    contView.layer.cornerRadius = 10;
    contView.layer.masksToBounds = YES;
    [self.contentView addSubview:contView];
    [contView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.left.top.offset(14);
        make.right.offset(-14);
    }];
    
    self.titleL = [BRToolsView br_label:@"--" textColor:kColorTitle font:[UIFont fontS:17] textAlignment:NSTextAlignmentLeft];
    self.subL = [BRToolsView br_label:@"--" textColor:kColorTitle font:[UIFont fontS:17] textAlignment:NSTextAlignmentRight];
    self.timeL = [BRToolsView br_label:@"--" textColor:kColorTitle font:[UIFont fontM:13] textAlignment:NSTextAlignmentLeft];
    
    [contView addSubview:self.titleL];
    [contView addSubview:self.subL];
    [contView addSubview:self.timeL];
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(14);
        make.left.offset(14);
    }];
    [self.subL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(14);
        make.right.offset(-14);
    }];
    [self.timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleL.mas_bottom).offset(14);
        make.left.offset(14);
        make.bottom.offset(-14);
    }];
}

- (void)setDto:(BRInviteHistoryModel *)dto {
    _dto = dto;
///暂定字段
//    NSString *account = dto.account;
//    
//    NSString *new = @"*******";
//    if (account.length > 4) {
//        new = [NSString stringWithFormat:@"%@%@",new,[account substringFromIndex:account.length - 4]];
//    }
//    
//    self.titleL.text = new;
//    self.timeL.text = [BRTools getTimeFromTimestamp:dto.createTime.integerValue formatter:kTimeFormatter];
//    NSString *pointStr = [BRPayManager br_amount:dto.amount];
//    NSInteger type = dto.type;
//    if (type == 1) {
//        pointStr = [NSString stringWithFormat:@"+%ld",dto.point];
//    }else if (type == 2) {
//        
//        // 抵扣类型：1-金额 2-时间 3-折扣
//        NSInteger couponType = dto.couponInfo.deductionType;
//        NSString *title2 = [BRStringTools br_couponsTypeStr:couponType];
//        NSString *text2 = [BRStringTools br_couponsTypeContent:dto.couponInfo];
//        pointStr = [NSString stringWithFormat:@"%@ %@",title2,text2];
//    }
//    self.subL.text = pointStr;
    
    self.titleL.text = Localized(@"Rewards_inviteAFriend");
    self.timeL.text = [BRTools getTimeFromTimestamp:dto.createTime.integerValue formatter:kTimeFormatter];
    NSString *pointStr = [BRPayManager br_amount:dto.amount];
    NSInteger type = dto.type;
    if (type == 1) {
        pointStr = [NSString stringWithFormat:@"+%ld",dto.point];
    }else if (type == 2) {
        pointStr = Localized(@"Order_coupon");
    }
    self.subL.text = pointStr;
}

@end
